#ifndef CONSOLE_H
#define CONSOLE_H

#include <string>
#include <sstream>
#include <algorithm>
#include <iostream>
#include <vector>
#include "UniversalIncludes.h"
#include "Screen.h"
#include "DrawHelper.h"

/*
 * Reads logs and presents it within the game.
 * TODO: Callbacks, input parser, display list around text, screen manager
 * to make other screens not updatable/eventable, popup animation of console
 * FIX: Output scrolling offset.
 */
class Console : public Screen
{
    // Fields
    private:
        int lineCount;                              // Number of lines to display
        GLuint bgDisp;
        int bgHeight;
        int fontSize;
        Texture2D* font;
        std::string inputText;
        int outputScroll;                           // Scroll offset for console output
        std::vector<std::string> previousInput;     // A history of previous commands entered
        std::vector<ConsoleMethod*> methods;
        unsigned int previousInputPos;

    // Methods
    public:
        Console();
        virtual ~Console() {};
        void draw();
        void handleEvents(SDL_Event* event);
        void addMethod(ConsoleMethod* m);
    private:
        std::vector<std::string> splitStringBySpaces(std::string* s);
        void parseInput(std::string* input);
        void renderText();
        // Default console metohds
        void quit(std::string s, std::vector<std::string> args);    // Sends singal to quit engine
        void help(std::string s, std::vector<std::string> args);    // Prints help: list of known commands/methods
};

#endif
